import { defineStore } from 'pinia';

export default defineStore({
  id: 'common',
  state: () => {
    return {
      systemInfo: {},
      isPageScroll: true, // 页面是否可以滚动，用于阻止打开弹窗后，禁止底部页面滚动,
      renew: false, // app 是否需要更新
      renewInfo: null, // app 更新的信息
      cityList: [],
      noticeNums: 0, // 未读消息数量
      renew: false, // app 是否需要更新
      renewInfo: null // app 更新的信息
    };
  },
  actions: {
    setSystemInfo() {
      const system = uni.getSystemInfoSync();
      const params = {
        appId: system.appId,
        deviceBrand: system.deviceBrand, // 设备品牌 apple、huawei、xiaomi、vivo、oppo、samsung、oneplus
        deviceModel: system.deviceModel, // 设备型号
        osName: system.osName, // 设备系统 ios、android
        appVersion: system.appVersion,
        appVersionCode: system.appVersionCode,
        appName: system.appName, // app名称
        statusBarHeight: system.statusBarHeight, // 手机状态栏的高度
        screenWidth: system.screenWidth, // 屏幕宽度
        screenHeight: system.screenHeight // 屏幕高度
      };
      this.systemInfo = params;
    },
    setPageScroll(data) {
      this.isPageScroll = data;
    },
    setRenew(renew, renewInfo) {
      this.renew = renew;
      this.renewInfo = renewInfo;
    },
    setCityList(data) {
      this.cityList = data;
    },
    setNoticeNums(data) {
      this.noticeNums = data;
    },
    setRenew(renew, renewInfo) {
      this.renew = renew;
      this.renewInfo = renewInfo;
    }
  }
});
